package main.swing;

import java.awt.BorderLayout;
import java.util.List;

import javax.swing.JFrame;
import javax.swing.JTextArea;

import main.bean.Email;
import main.inte.Pop4recv;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JMenu;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

public class Main extends JFrame {
	JTextArea textArea;
	public Main() {
		BorderLayout borderLayout = (BorderLayout) getContentPane().getLayout();
		borderLayout.setHgap(10);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		textArea = new JTextArea();
		
		getContentPane().add(textArea, BorderLayout.EAST);
		
		JMenuBar menuBar = new JMenuBar();
		setJMenuBar(menuBar);
		
		JMenu mnNewMenu = new JMenu("File");
		menuBar.add(mnNewMenu);
		
		JMenuItem mntmNewEmial = new JMenuItem("New Email");
		mntmNewEmial.setEnabled(false);
		mnNewMenu.add(mntmNewEmial);
		
		JMenu mnNewMenu_1 = new JMenu("Sys");
		menuBar.add(mnNewMenu_1);
		
		JMenuItem mntmUserAccount = new JMenuItem("User Account");
		mntmUserAccount.setEnabled(false);
		mnNewMenu_1.add(mntmUserAccount);
		
		JMenuItem mntmExit = new JMenuItem("Exit");
		mntmExit.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				System.exit(0);
			}
		});
		mnNewMenu_1.add(mntmExit);
	}
	public static void main(String[] args){
		Main m = new Main();
		m.setVisible(true);
		Pop4recv pop = new Pop4recv();
		List<Email> list = pop.recp();
		for(Email e : list){
			m.textArea.append(e.getSubject() + "\n");
		}
	}
}
